﻿using QuanLyChoVayCaNhan.Forms;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace QuanLyChoVayCaNhan.Classes
{
    public class WindowsManager
    {
        private Form fCurrentPrimary = null;
        private Form fDangNhap = null;
        private Form fMain = null;
        private NhanVienTab tNhanVien = null;
        private KhachHangTab tKhachHang = null;
        private TiepNhanHoSoTab tTiepNhanHoSo = null;
        private ThamDinhTinDungTab tThamDinhTinDung = null;
        private ThamDinhTaiSanDamBaoTab tThamDinhTaiSanDamBao = null;

        private static WindowsManager INSTANCE = new WindowsManager();

        public static WindowsManager GetInstance()
        {
            return INSTANCE;
        }

        // private swich to form
        private void showForm(Form f)
        {
            fCurrentPrimary.Close();
            fCurrentPrimary = f;
            f.Show();
        }
        // hien form dang nhap
        public void ShowFirstWindow()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            if (fDangNhap == null) fDangNhap = new DangNhapForm();
            Application.Run(fDangNhap);
        }

        public void LoggedInAndShowMainForm()
        {
            if (fMain == null) fMain = new MainForm();
            fMain.Show();
            fDangNhap.Visible = false;
        }
        public void LogoutAndShowLoginForm()
        {
            fMain.Close();
            fMain = null;
            fDangNhap.Visible = true;
        }
        public NhanVienTab TabNhanVien
        {
            get
            {
                return tNhanVien;
            }
            set
            {
                tNhanVien = value;
            }
        }

        public KhachHangTab TabKhachHang
        {
            get
            {
                return tKhachHang;
            }
            set
            {
                tKhachHang = value;
            }
        }

        public TiepNhanHoSoTab TabTiepNhanHoSo
        {
            get
            {
                return tTiepNhanHoSo;
            }
            set
            {
                tTiepNhanHoSo = value;
            }
        }

        public ThamDinhTinDungTab TabThamDinhTinDung
        {
            get
            {
                return tThamDinhTinDung;
            }
            set
            {
                tThamDinhTinDung = value;
            }
        }
        public ThamDinhTaiSanDamBaoTab TabThamDinhTaiSanDamBao
        {
            get
            {
                return tThamDinhTaiSanDamBao;
            }
            set
            {
                tThamDinhTaiSanDamBao = value;
            }
        }
    }
}
